package com.shph.validation.adapter.impl;

import com.shph.validation.adapter.RuleParse;
import com.shph.validation.rule.IRule;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ClassRuleParse implements RuleParse<Class> {
    @Override
    public IRule parse(Class clazz) {
        Object o = null;
        try {
            o = clazz.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            log.error(e.getMessage());
        }

        if (o instanceof IRule) {
            return (IRule) o;
        }

        return null;
    }
}
